

<?php
// $categoryId = $this->getRequest()->getParam('category');

$store = Mage::app()->getStore()->getId();
// $showFeaturedBrands = Mage::getStoreConfig('shopbybrand/brand_list/display_featured_brand', $store);
// $showBrandCategories = Mage::getStoreConfig('shopbybrand/brand_list/display_brand_category', $store);
// $showCharatersList = Mage::getStoreConfig('shopbybrand/brand_list/display_brand_character_list', $store);
// $showSearchBox = Mage::getStoreConfig('shopbybrand/brand_list/display_brand_search_box', $store);
// $showLogoImage = Mage::getStoreConfig('shopbybrand/brand_list/display_brand_image', $store);
// $brandsListStyle = Mage::getStoreConfig('shopbybrand/brand_list/display_brand_group_by_name', $store);
$logo_width = Mage::getStoreConfig('shopbybrand/brand_list/brand_logo_width', $store);
$logo_height = Mage::getStoreConfig('shopbybrand/brand_list/brand_logo_height', $store);
// $showNumberOfProducts = Mage::getStoreConfig('shopbybrand/brand_list/display_product_number', $store);
// $onlyBrandHaveProduct = Mage::getStoreConfig('shopbybrand/brand_list/display_brand_have_product', $store);
$attribute = Mage::getSingleton('eav/config')->getAttribute('catalog_product','brand');
$_category_id = Mage::getModel('catalog/category')->loadByAttribute('name','全部分类')->getData('entity_id');
?>

<div class="brand-title">
<h3>爆款产品</h3>
</div>
<div class="brands">
    <ul class="col slides">
        <?php
//                $baseUrl = $this->getBaseUrl();
        $shopbybrands = Mage::getSingleton('shopbybrand/brand')->getBrandsData();
        $noImg = '';
        if ($shopbybrands[0]) {
            $path = 'brands/thumbnail' . DS . $shopbybrands[0]['brand_id'];
            $noImg = Mage::helper('shopbybrand/image')
                    ->resizeThumbnail1('', $path, $logo_width, $logo_height);
        }

        $proCount = count($shopbybrands);
        $colSize = 2;
        $i =0;
        foreach ($shopbybrands as $brand):
       // print_r($brand['name']);
        if ($attribute->usesSource()) {
            $option_id = $attribute->getSource()->getOptionId($brand['name']);
            
        } ?>
                <?php if($i++%$colSize==0):?>

                <li>
                <?php endif;?>
                <div class="brand-con">
                    <?php 
                    $brand_data = Mage::getModel('shopbybrand/brand')->setStoreId($storeId)
                    ->load($brand['brand_id']);
                    if($brand_data->getBannerUrl()){
                        $url = $brand_data->getBannerUrl();
                        //echo '1'.$url;
                    }else{
                        $url ="";
                    }
                    ?>
                    <?php //echo '2'.$url;?>
                    <a href="<?php echo Mage::app()->getStore()->getUrl($url); ?>">
                        <?php
                        $path = 'brands/thumbnail' . DS . $brand['brand_id'];

                        $img = ($brand['thumbnail_image'] == NULL) ? $noImg : Mage::helper('shopbybrand/image')
                                        ->resizeThumbnail1($brand['thumbnail_image'], $path, $logo_width, $logo_height);
                        ?>
                        <?php if($img):?>
                        <img src="<?php echo $img; ?>" alt="<?php echo ucfirst($brand['name']); ?>" title="<?php echo ucfirst($brand['name']); ?>" />
                        <?php else:?>
                            
                        <?php endif;?>
                        
                    </a>
                </div>
                <?php if($i%$colSize==0 & $i==$proCount ):?>    
                </li>
                <?php endif;?>
            <?php
        endforeach;
        ?>            
    </ul>
</div>
<div class="brandicons">
<?php if($proCount >5):?>
<div class="prev">prev</div>
<div class="next">next</div>
<?php endif;?>
    <div><a href="<?php echo $this->getBaseUrl('').'catalog/category/view/id/12'?>">查看更多</a></div>
</div>
<?php if($proCount >5):?>
<script type="text/javascript">
jQuery(function() {
var page = 1;
var i = 2;
var conheight = jQuery('.brands li').height();
var lilen = jQuery('.brands li').length;
var len = Math.ceil( lilen - i )+1;
jQuery('.brandicons .next').click(function() {
if( page == len ) {

jQuery('.brands .col').animate({top:0},'slow');
page = 1;
}else{
jQuery('.brands .col').animate({top:'-=' + conheight},'slow');
page++;
}
});
jQuery('.brandicons .prev').click(function() {
if( page == 1 ) {
jQuery('.brands .col').animate({top:'-=' + conheight*(len - 1)},'slow');
page = len;
}else{
jQuery('.brands .col').animate({top:'+=' + conheight},'slow');
page--;
}
});
})
</script>
<?php endif;?>